#pragma once
#ifndef TOFTLIB_EXTENDEXCEPTION_INTERFACE_H
#define TOFTLIB_EXTENDEXCEPTION_INTERFACE_H

/**
 * @file ExtendedException.h
 * @author ActiveMQ
 */

#include <exception>
#include <string>
#include <vector>
#include <stdio.h>

#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
#define __WFILE__ WIDEN(__FILE__)

namespace toftlib
{
    /**
     * @class ExtendedException
     * @brief This class represents an error that has occurred.Copy from ActiveMQ
     */

    class ExtendedException : public std::exception
    {
    public:
        ExtendedException(void) throw() {};
        virtual ~ExtendedException(void) throw() {};

        /**
		 * Gets the cause of the error.
		 * @return string errors message
		 */
		virtual std::wstring getMessage() const = 0;

        /**
		 * Adds a file/line number to the stack trace.
         *
		 * @param file The name of the file calling this method (use __FILE__).
		 * @param lineNumber The line number in the calling file (use __LINE__).
		 */
		virtual void setMark( const wchar_t* file, const int lineNumber ) = 0;

        /**
		 * Clones this exception.  This is useful for cases where you need
		 * to preserve the type of the original exception as well as the message.
		 * All subclasses should override.
         *
		 * @return Copy of this Exception object
		 */
		virtual ExtendedException* clone() const = 0;

        /**
		 * Provides the stack trace for every point where
		 * this exception was caught, marked, and rethrown.
         *
		 * @return vector containing stack trace strings
		 */
		virtual std::vector< std::pair< std::wstring, int> > getStackTrace() const = 0;

        /**
		 * Prints the stack trace to std::err
		 */
		virtual void printStackTrace() const = 0;

        /**
		 * Prints the stack trace to the given output stream.
		 * @param stream the target output stream.
         *
		 */
		virtual void printStackTrace( std::wostream& stream ) const = 0;

        /**
		 * Gets the stack trace as one contiguous string.
         *
		 * @return string with formatted stack trace data
		 */
		virtual std::wstring getStackTraceString() const = 0;
    };
}

#endif
